package smallTools_testCase;

import junit.framework.TestCase;
import smallTools.SimpleTime;
import smallTools.TimeSlotUtility;

public class TimeSlotUtilityTest extends TestCase {
	private TimeSlotUtility TSU;

	public void setUp() {
		TSU = new TimeSlotUtility();
	}

	// Test case 1
	public void test_getFirstTimeSlot() {
		SimpleTime firstStartTime = TSU.getFirstTimeSlot();
		assertEquals("Mon 11:30", firstStartTime.toString());
	}

	// Test case 2
	public void test_getNextTimeSlot() {
		TSU.getFirstTimeSlot();
		SimpleTime secondStartTime = TSU.getNextTimeSlot(1);
		assertEquals("Tue 11:30", secondStartTime.toString());
	}

	// Test case 3: From Mon 21:30 jump to Mon 10:30
	public void test_EveningTime() {
		SimpleTime startTime = TSU.getFirstTimeSlot();
		
		// move to Fri 20:30
		for (int i = 0; i < 5 * 10 - 1; i++)
			startTime = TSU.getNextTimeSlot(2);
		assertEquals("Fri 20:30", startTime.toString());
		
		// test next time slot
		startTime = TSU.getNextTimeSlot(2);
		assertEquals("Mon 10:30", startTime.toString());
	}
	
	// Test case 4: null
	public void test_null() {
		SimpleTime startTime = TSU.getFirstTimeSlot();
		
		// move to Fri 20:30
		for (int i = 0; i < 5 * 10 - 1; i++)
			startTime = TSU.getNextTimeSlot(2);
		assertEquals("Fri 20:30", startTime.toString());
		
		// move to Fri 8:30
		for (int i = 0; i < 5 * 3; i++)
			startTime = TSU.getNextTimeSlot(2);
		assertEquals("Fri 08:30", startTime.toString());
		
		// test next time slot
		startTime = TSU.getNextTimeSlot(2);
		assertEquals(null, startTime);
	}
}
